package org.op.editor.doc;

import org.op.FrameView;
import org.op.editor.EditorComponentView;
import org.op.service.config.ConfigurationService;
import org.op.service.doc.ClipboardService;
import org.op.service.log.LoggerService;
import org.op.util.MessageController;

public class CuCoPaControllerImpl implements CuCoPaController {

	private EditorComponentView editorView;
	private ClipboardService clipboardService;
	private ConfigurationService configService;
	private MessageController messageController;
	private FrameView frameView;
	private LoggerService logger;
	
	public void clearAll() {
		editorView.getCurrentPane().setText("");
		editorView.setCurrentDirty();
	}

	public void copyToClipboard() {
		//String text = editorView.getCurrentPane().getSelectedText();
		String text = editorView.getSelectedText();
		clipboardService.addTextToClipboard(text);
	}

	public void cutToClipboard() {
		//String text = editorView.getCurrentPane().getSelectedText();
		String text = editorView.getSelectedText();
		clipboardService.addTextToClipboard(text);
		editorView.getCurrentPane().replaceSelection("");
		editorView.setCurrentDirty();
	}

	public void pasteFromClipboard() {
		String cliptext = clipboardService.getTextFromClipboard();
		editorView.getCurrentPane().replaceSelection(cliptext);
		
		editorView.setCurrentDirty();
	}

	public void selectAll() {
		editorView.getCurrentPane().setSelectionStart(0);
		int endIdx = editorView.getCurrentPane().getText().length();
		editorView.getCurrentPane().setSelectionEnd(endIdx);
	}

	public EditorComponentView getEditorView() {
		return editorView;
	}

	public void setEditorView(EditorComponentView editorView) {
		this.editorView = editorView;
	}

	public ClipboardService getClipboardService() {
		return clipboardService;
	}

	public void setClipboardService(ClipboardService clipboardService) {
		this.clipboardService = clipboardService;
	}

	public ConfigurationService getConfigService() {
		return configService;
	}

	public void setConfigService(ConfigurationService configService) {
		this.configService = configService;
	}

	public MessageController getMessageController() {
		return messageController;
	}

	public void setMessageController(MessageController messageController) {
		this.messageController = messageController;
	}

	public FrameView getFrameView() {
		return frameView;
	}

	public void setFrameView(FrameView frameView) {
		this.frameView = frameView;
	}

	public LoggerService getLogger() {
		return logger;
	}

	public void setLogger(LoggerService logger) {
		this.logger = logger;
	}

}
